package com.dk.controller;

import com.dk.pojo.TabRoute;
import com.dk.pojo.TabRouteImg;
import com.dk.service.TabRouteImgService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;
@Controller
@RequestMapping("tabRouteImg")
public class TabRouteImgController {

    @Autowired
    private TabRouteImgService tabRouteImgService;

    @RequestMapping("toShow")
    public String toShow(){
        return "tabRouteImg/show";
    }
    @RequestMapping("getInfo")
    @ResponseBody
    public List<TabRouteImg> getInfo(Integer rid){
        List<TabRouteImg> result = tabRouteImgService.getInfo(rid);
        return result;
    }
    @RequestMapping("toAdd")
    public String toAdd(){
        return "tabRouteImg/add";
    }
    @RequestMapping("increase")
    @ResponseBody
    public boolean insertInfo(TabRouteImg tabRouteImg){
        return tabRouteImgService.insert(tabRouteImg) > 0;
    }
    @RequestMapping("toUpdate/{id}")
    public String toUpdate(@PathVariable("id")Integer rgid, Model model){
        TabRouteImg tabRouteImg = tabRouteImgService.selectById(rgid);
        model.addAttribute("tabRouteImg",tabRouteImg);
        return "tabRouteImg/update";
    }
    @RequestMapping("updateInfo")
    @ResponseBody
    public boolean updateInfo(TabRouteImg tabRouteImg){
        return tabRouteImgService.updateInfo(tabRouteImg) > 0;
    }
    @RequestMapping("deleteById")
    @ResponseBody
    public boolean deleteById(Integer rgid){
        return tabRouteImgService.deleteById(rgid) > 0;
    }
}
